Conditions | 1 |
Paths | 1 |
Total Lines | 62 |
Lines | 62 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /*! |
||
9 | describe("4-bit IMA ADPCM reading", function() { |
||
10 | |||
11 | let fs = require("fs"); |
||
12 | let wavefile = require("../index.js"); |
||
13 | let path = "test/files/"; |
||
14 | |||
15 | let wBytes = fs.readFileSync(path + '4bit-imaadpcm-8kHz-noBext-mono.wav'); |
||
16 | let wav = new wavefile.WaveFile(wBytes); |
||
17 | |||
18 | it("chunkId should be 'RIFF'", |
||
19 | function() { |
||
20 | assert.equal(wav.chunkId, "RIFF"); |
||
21 | }); |
||
22 | it("subChunk1Id should be 'fmt '", |
||
23 | function() { |
||
24 | assert.equal(wav.subChunk1Id, "fmt "); |
||
25 | }); |
||
26 | it("format should be 'WAVE'", |
||
27 | function() { |
||
28 | assert.equal(wav.format, "WAVE"); |
||
29 | }); |
||
30 | it("subChunk1Size should be 20", |
||
31 | function() { |
||
32 | assert.equal(wav.subChunk1Size, 20); |
||
33 | }); |
||
34 | it("audioFormat should be 17 (IMA ADPCM)", |
||
35 | function() { |
||
36 | assert.equal(wav.audioFormat, 17); |
||
37 | }); |
||
38 | it("numChannels should be 1", |
||
39 | function() { |
||
40 | assert.equal(wav.numChannels, 1); |
||
41 | }); |
||
42 | it("sampleRate should be 8000", |
||
43 | function() { |
||
44 | assert.equal(wav.sampleRate, 8000); |
||
45 | }); |
||
46 | it("bitsPerSample should be 4", |
||
47 | function() { |
||
48 | assert.equal(wav.bitsPerSample, 4); |
||
49 | }); |
||
50 | it("factChunkId should be 'fact'", |
||
51 | function() { |
||
52 | assert.equal(wav.factChunkId, 'fact'); |
||
53 | }); |
||
54 | it("factChunkSize should be 4", |
||
55 | function() { |
||
56 | assert.equal(wav.factChunkSize, 4); |
||
57 | }); |
||
58 | it("subChunk2Id should be 'data'", |
||
59 | function() { |
||
60 | assert.equal(wav.subChunk2Id, 'data'); |
||
61 | }); |
||
62 | it("subChunk2Size should be > 0", |
||
63 | function() { |
||
64 | assert.ok(wav.subChunk2Size > 0); |
||
65 | }); |
||
66 | it("samples.length should be > 0", |
||
67 | function() { |
||
68 | assert.ok(wav.samples_.length > 0); |
||
69 | }); |
||
70 | }); |
||
71 |